#include<algorithm>

class Solution {
private:
    double myPow1(double x, int n) {
        if (n == 0) return 1;
        double res = myPow(x, n / 2);
        return res * res * (n % 2 ? x : 1);
    }
public:
    double myPow(double x, int n) {
        double res = myPow1(x, abs(n));
        if (res == 0)
            return 0;
        return n > 0 ? res : 1 / res;
    }
};